package com.itzol.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itzol.config.Result;
import com.itzol.entity.Sushi;
import com.itzol.service.SushiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author linxin
 * @since 2021-12-14
 */
@RestController()
public class SushiController {
      @Autowired
      private SushiService sushiService;
      // 获取sushi名字 先判断 是否存在
      @PostMapping("/sushi")
      public Result sushi(@RequestBody Sushi sushi){
          QueryWrapper wrapper = new QueryWrapper();
          wrapper.eq("SuShiName",sushi.getSushiName());
          Sushi sushi1 = sushiService.getOne(wrapper);
          if(sushi!=null){
              return Result.erreo("寿司已经存在,勿重复添加");
          }
          else {
              Boolean result= sushiService.save(sushi);
              return Result.succ("添加成功");
          }
      }
}

